
import {$} from "../util/seq.js";

/**
 * @param container
 * @param {Handle} handle
 */
export function defineNoticeCard(container, handle) {
    const field = container.select(".field");
    const closeButton = container.select("button");

    function updateDOM() {
        const message = handle.get();
        container.property("hidden", (message ?? "") === "");
        field.text(message);
    }

    handle.on($`change`, updateDOM);
    closeButton.on($`click`, () => handle.set(undefined));
}
